<template>
  <div>
    <div><input type="text" data-test="username" placeholder="用户名" v-model="userName" /></div>
    <div><input type="text" data-test="password" placeholder="密码" v-model="password" /></div>
    <div><input type="text" data-test="confirm-password" placeholder="确认密码" v-model="confirmPassword" /></div>
    <div>
      <button data-test="register" @click="register">注册</button>
    </div>
  </div>
</template>
<script>

import userService from '@/api/service/userService'

export default {
  name: 'Register',
  data () {
    return {
      userName: '',
      password: '',
      confirmPassword: ''
    }
  },
  methods: {
    async register () {
      await userService.register({
        userName: this.userName,
        password: this.password
      })
      this.$router.push({
        name: 'Login'
      })
    }
  }
}
</script>
